package com.game;

/**
 * 猜拳游戏（面向对象编写）
 * 1.基本规则：剪刀石头布，剪刀>布>石头>剪刀； 剪刀0，布1，石头2
 * 2.电脑随机生成，人则是输入
 * 3.然后比较，出拳相同积1分，赢+3分，输了扣3分循环十轮比较双方分数高低，输出不同语句
 */
public class FingerGuess {
    public static Computer computer = new Computer();
    public static Player player = new Player();

    public static void main(String[] args) {
        FingerGuess fingerGuess = new FingerGuess();
        fingerGuess.judge();
    }

    //判断
    //猜拳比较方法
    public void judge() {
        int playerScore = 0;
        for (int i = 1; i < 10; i++) {//循环多少局 10局
            switch (player.generate() - computer.generate()) {
                //平局
                case 0:
                    System.out.println("第" + (i ) + "局，平局+1分");
                    //+1分
                    playerScore += 1;
                    break;
                    //输的局
                case 1:
                case -1:
                    System.out.println("第" + (i ) + "局，这一局玩家输了，-3分");
                    playerScore -= 3;
                    break;
                    //赢的局
                case 2:
                case -2:
                    //+3分
                    System.out.println("第" + (i ) + "局，这一局玩家赢了，+3分");
                    playerScore += 3;
                    break;
            }
        }
        String str = "";
        if (playerScore > 0) {
            str = "恭喜获胜~";
        } else {
            str = "惜败~";
        }
        System.out.println("你的分数为：" + playerScore + "。" + str);
    }

}